package com.manbu.live.farmework.datasource.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * @author hanWang
 * @Title:
 * @Package
 * @Description: 由于 配置中的 hikari 数据库无法对shardingjdbc 进行初始化连接池 所以使用这个方式
 * @date 2024/1/217:33 下午
 *
 */
@Configuration
public class ShardingJdbcDatasourceAutoInitConnectionConfig {
   private static final Logger log =  LoggerFactory.getLogger(ShardingJdbcDatasourceAutoInitConnectionConfig.class);


   @Bean
    public ApplicationRunner runner(DataSource datasource){

      return args -> {
         log.info("dataSource:{}",datasource);
         Connection connection = datasource.getConnection();
      };


   }

}
